package com.mijie.fentsi;

import java.util.List;
import java.util.Set;

import com.mijie.homi.search.util.listUtil;

/**
 * fentsi controler word from db
 * @author Administrator
 *
 */
public class fentsiCa22 extends fentsiOr {

	fentsiOr ftc;
	public String filt(String sFentsi) {
		String article = "c:\\fentsiOK.txt";
		String syvtsiLib = "c:\\word\\word_syvtsi.txt";
		String target = "c:\\fentsiOK_filted.txt";
if(ftc==null)
		  ftc = new fentsiOr();
		//ftc.filtSyvtsi(article, target, syvtsiLib);
		
		String filted = ftc.filtSyvtsiSingleLine(sFentsi, "\\|", syvtsiLib);
		return filted;
	}
	/**
	 * cb4
	 */
	Set syvtsiLib;
	public List<String> renvaEventKws;
	/**
	 * @author attilax 1466519819@qq.com
	 * @param sFentsi   a|b|c
	 * @return
	 */
	public String filtBydb(String sFentsi) {
		if (ftc == null)
			ftc = new fentsiOr();
		// ftc.filtSyvtsi(article, target, syvtsiLib);
		String[] a = sFentsi.split("\\|");
		listUtil luc=new listUtil();
		
		iniStopWordLib(luc);

		String filted = ftc.filtSyvtsiSingleLine(a, WordsLibController. syvtsiLib);
		return filted;
	}
	void hanbinStopWordN_RenvaEventKws()
	{
		Set syvtsiLib=WordsLibController.syvtsiLib;
		for(String kw:WordsLibController.RenvaEventKws)
		{
			if(syvtsiLib.contains(kw))
				syvtsiLib.remove(kw);
		 
		}
		WordsLibController.syvtsiLib=syvtsiLib;
	}
	void iniStopWordLib(listUtil lucx) {
		if(WordsLibController.syvtsiLib==null)
		if(syvtsiLib==null)
		{
			listUtil luc=new listUtil();
		  syvtsiLib=luc.getSetFromdb("select  word from word_syvtsi where del=0 ");
		 
		  
			//cbe
		//	List<String> renvaKws=fentsiController_cbb.renvaEventCon.renvaKws;
			
//			List<String> eventKws=fentsiController_cbb.renvaEventCon.eventKws;
//			for(String kw:eventKws)
//			{
//				if(syvtsiLib.contains(kw))
//					syvtsiLib.remove(kw);
//			}
			////cbe
		  
			WordsLibController.syvtsiLib=syvtsiLib;
		}
	}
	
	/**
	 * 
	 * @param sFentsi
	 * @param splitor
	 * @return
	 */
	public String filtBydb(String sFentsi,String splitor) {
		if (ftc == null)
			ftc = new fentsiOr();
		// ftc.filtSyvtsi(article, target, syvtsiLib);
		String[] a = sFentsi.split(splitor);
		listUtil luc=new listUtil();
		
		if(syvtsiLib==null)
		//  syvtsiLib=luc.getSetFromdb("select  word from word_syvtsi where del=0 ");
			syvtsiLib=WordsLibController.syvtsiLib;

		String filted = ftc.filtSyvtsiSingleLine(a, syvtsiLib);
		filted=listUtil.deDulicate(filted, " ");
		return filted;
	}


}
